/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Primitive;

import Common.IUnitHolder;
import Components.IPrimitive;
import Project.Unit;
import java.awt.Color;
import java.awt.Point;
import java.awt.Shape;

/**
 *
 * @author Администратор
 */
public abstract class Primitive extends Unit implements IPrimitive {

    
    Shape border;

    public Primitive(IUnitHolder unitHolder, int x, int y) {
        super(unitHolder);
        this.setAttribute("PositionX").setValue(x);
        this.setAttribute("PositionY").setValue(y);
        this.setAttribute("Fill").setValue(Color.black);
        this.setAttribute("Border").setValue(0);
        this.setAttribute("BorderColor").setValue(Color.black);
        this.setAttribute("Angle").setValue(0);
        this.setAttribute("Width").setValue(0);
        this.setAttribute("Height").setValue(0);
        border = new java.awt.Rectangle();
    }

    public void setPosition(Point point) {
       this.setAttribute("PositionX").setValue(point.x);
       this.setAttribute("PositionY").setValue(point.y);
    }

    public void setAngle(int angle) {
        this.getAttribute("Angle").setValue(angle);
    }

    public int getAngle() {
        return Integer.decode(this.getAttribute("Angle").getValue().toString());
    }

    public int getWidth() {
        return Integer.decode(this.getAttribute("Width").getValue().toString());
    }

    public int getHeight() {
        return Integer.decode(this.getAttribute("Height").getValue().toString());
    }

    public void setBorderColor(Color color) {
        this.getAttribute("BorderColor").setValue(color);
    }

    public Color getBorderColor() {
        return (Color) this.getAttribute("BorderColor").getValue();
    }

    public void setFill(Color color) {
        this.setAttribute("Fill").setValue(color);
    }

    public Point getPosition() {
        return new Point(Integer.decode(this.setAttribute("PositionX").getValue().toString()),
                Integer.decode(this.setAttribute("PositionY").getValue().toString()));
    }

    public void setSize(int width, int height) {
        this.setAttribute("Width").setValue(width);
        this.setAttribute("Height").setValue(height);
    }

    public Color getFill() {
        return (Color) this.setAttribute("Fill").getValue();
    }
}
